﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NENAData.Factory;
using NENAData.LINQ;
using NENAData.NENAProvinces;

namespace NENAData.Transactions.Payments.Other
{
    class OtherTransactions
    {
        private static MembershipDataContext GetMembershipDB()
        {
            var x = new SQLMembership();
            return x.GetMembershipDB();
        }

        public void NewPayment(int intMemberId, int intPaymentTo, TransactionList.Transactions oTransaction)
        {
            MembershipDataContext db = GetMembershipDB();

            NENAAffiliate oNENAAffiliate = new NENAAffiliate();
            Affiliate oAffiliate = new Affiliate();

            oAffiliate = oNENAAffiliate.GetAffiliate_byAffiliateID(intPaymentTo);

            TransactionPayment NENAtransaction = new TransactionPayment
            {
                Member_ID = intMemberId,
                PaymentTo = intPaymentTo,
                PaymentAmount = Convert.ToDouble(oAffiliate.Membership_Fee),
                TransactionCompleted = true,
                PaymentType = "unknown",
                PaymentMethod = "Manual",
                PaymentStatus = "Paid by Other",
                PaymentReason = "MembershipFees",
                PaymentDate = DateTime.Now,
                TransactionID_NENA = (Int32)oTransaction
            };

            db.TransactionPayments.InsertOnSubmit(NENAtransaction);
            db.SubmitChanges();
        }
    }
}
